# encoding: utf-8

import configparser

# 初始化类，打开配置文件
cf = configparser.ConfigParser()
cf.read(r'./sqlserver_db_init.ini')

# # 读方法 --------------------------------------------------------------
secs = cf.sections()
print(secs)
#
# opts = cf.options("db")
# print(opts)
#
# kvs = cf.items("127.0.0.1_3306_cjg2cxstar")
# print(kvs)
#
# kl = cf.get("127.0.0.1_3306_cjg2cxstar", "port")
# print(kl)

# 写方法 -----------------------------------------------------------------
# 添加 --------
# cf.set("db", "b_key3", "new-$r")
# cf.set("db", "b_newkey", "new-value")
#
# 添加新 [配置] 时需要执行 write操作，否则新 [配置] 不会被写入文件
# cf.add_section('127.0.0.1_3306_cjg2cxstar3')
# cf.set("127.0.0.1_3306_cjg2cxstar3", "server_name", "127.0.0.1")
# cf.set("127.0.0.1_3306_cjg2cxstar3", "port", "3306")
# cf.set("127.0.0.1_3306_cjg2cxstar3", "db_name", "cjg2cxstar")
# cf.set("127.0.0.1_3306_cjg2cxstar3", "username", "root")
# cf.set("127.0.0.1_3306_cjg2cxstar3", "password", "root23")
# cf.write(open("./sqlserver_db_init.ini", "w"))

# 删除 --------
# 删除 [配置] 时需要执行 write操作，否则 [配置] 不会从文件中删除
# cf.remove_section('127.0.0.1_3306_cjg2cxstar2')
# cf.write(open("./sqlserver_db_init.ini", "w"))

# 删除 [配置] 中的key 时需要执行 write操作，否则 key 不会从文件中删除
# cf.remove_option('a_new_section', 'new_key')
# cf.write(open("./sqlserver_db_init.ini", "w"))

import json

#
# txt = '[{"10100001": "燃煤烟气汞排放控制 英文\u001f", "wfstatus": "A", "7": "A", "customercode": "1878", "siteid": "urmp", "20100001": "publicpost", "RUID": "jmu_sqlserver_no2_sckj2cxstarTP_sc_book_pdf_99003948"}]'
# txt = txt.replace("\\", "\\\\")
# print(txt)

# data_dict_list = [{"10100001": "燃煤烟气汞排放控制 英文\u001f"}]
# json_dic = json.dumps(data_dict_list, ensure_ascii=False).replace("\\", "\\\\")
# # json_dic = json.loads(txt, strict=False)
#
# print(json_dic)
# print(type(json_dic))
#
# list1 = [1, 23, 3, 'faff']
# list1.insert(0, '不导入')
# print(list1)